package com.smartum.mpr.dao;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.smartum.mpr.model.ItemSubCategory;

@Repository
public class ItemSubCategoryDao extends GenericDao<Long, ItemSubCategory> {


	public List<ItemSubCategory> getSubCategoriesByCategoryId(Long categoryID) {
		DetachedCriteria critteria = DetachedCriteria.forClass(ItemSubCategory.class);
		critteria.createCriteria("category").add(Restrictions.eq("id", categoryID));
		List<ItemSubCategory> subcategories = hibernateTemplate.findByCriteria(critteria);
		return subcategories;
	}

	@Override
	protected Class<ItemSubCategory> getEntityClass() {
		return ItemSubCategory.class;
	}

}
